package org.zcl.单例;

/**
 * @PROJECT_NAME:
 * @DESCRIPTION: 饱汉，有就用，没有才new【 线程不安全，多线程环境下，如果多个线程同时进入了 if (uniqueInstance == null) ，若此时还未实例化，也就是uniqueInstance == null，那么就会有多个线程执行 uniqueInstance = new Singleton(); ，就会实例化多个实例；】
 * @USER: ZhuChengLin
 * @DATE: 2021/11/22 10:16
 */
public class Single3_1 {

    private static Single3_1 uniqueInstance;

    private Single3_1() {
    }

    public static synchronized Single3_1 getInstance() {
        if (uniqueInstance == null) {
            uniqueInstance = new Single3_1();
        }
        return uniqueInstance;
    }
}
